package com.syaccp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.syaccp.mapper.TOrderCategoryMapper;
import com.syaccp.model.OrderImage;
import com.syaccp.model.TOrderCategory;
import com.syaccp.model.TOrderImage;
import com.syaccp.service.TOrderImageService;
import com.syaccp.mapper.TOrderImageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author DX
* @description 针对表【t_order_image】的数据库操作Service实现
* @createDate 2023-07-25 09:12:38
*/
@Service
public class TOrderImageServiceImpl extends ServiceImpl<TOrderImageMapper, TOrderImage> implements TOrderImageService{

    @Autowired
    TOrderImageMapper tOrderImageMapper;


    @Resource
    private TOrderImageMapper orderImageMapper;

    @Resource
    private TOrderCategoryMapper categoryMapper;




    @Override
    public List<TOrderImage> QueryDetailImage(Integer id) {
        QueryWrapper<TOrderImage> qw=new QueryWrapper<>();
        qw.eq("task_id",id).ne("quanji_url"," ");
        List<TOrderImage> orderImages = orderImageMapper.selectList(qw);
        return orderImages;
    }

    @Override
    public Integer addImage(TOrderImage image) {
        if (image.getPicType()==2){
            image.setQuanjiUrl("oss");
        }
        Integer integer = orderImageMapper.addImage(image);
        return integer;
    }

    @Override
    public TOrderCategory selectOneById(Integer id) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("id",id);
        TOrderCategory orderCategory = categoryMapper.selectOne(queryWrapper);

        return orderCategory;
    }

    @Override
    public List<TOrderImage> queryImageByOrderId(Integer orderId) {
        LambdaQueryWrapper<TOrderImage> query= Wrappers.lambdaQuery(TOrderImage.class);
        query.eq(ObjectUtils.isNotEmpty(orderId),TOrderImage::getTaskId,orderId);
        return tOrderImageMapper.selectList(query);
    }



}




